<?php echo $this->render('/public/header'); ?>
    <script src="https://cdn.bootcss.com/element-ui/2.3.7/index.js"></script>
    <link href="https://cdn.bootcss.com/element-ui/2.3.7/theme-chalk/index.css" rel="stylesheet">
    <div id="main" class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1">
                <a class="btn btn-success" href="/setting/reimburse-add">报销登记</a>
            </div>
            <div id="vue_container"
                 class="col-lg-3 col-lg-offset-8 col-md-3 col-md-offset-8 col-sm-3 col-sm-offset-8 col-xs-3 col-xs-offset-8">
                <button @click="open" class="btn btn-success" style="width:120px">公司开发票信息</BUTTON>
                <span class="label label-success">总共报销:<?php echo $money; ?></span>
            </div>
        </div>

        <br/>
        <br/>
        <br/>
        <table class="table table-borderd" style="marginTop:10px">
            <thead>
            <tr>
                <th>申请日期</th>
                <th>报销时间</th>
                <th>报销金额</th>
                <th>数量</th>
                <th>名称</th>
                <th>报销凭证</th>
                <th>invoice</th>
                <td>客户编号</td>
                <th>客户全名</th>
                <th>性质</th>
                <th>类型</th>
                <th>国家</th>
                <th>备注</th>
                <th>审核状态</th>
                <th>打款状态</th>
            </tr>
            </thead>
            <tbody>
            <?php foreach ($list as $k => $v): ?>
                <?php $data = json_decode($v['detail'], true); ?>
                <tr>
                    <td><?php echo $data['date']; ?></td>
                    <td><?php echo $v['time'] > 0 ? date('Y-m-d H:i:s', $v['time']) : ''; ?></td>
                    <td><?php echo $data['fee']; ?></td>
                    <td><?php echo $data['number']; ?></td>
                    <td><?php echo $data['name']; ?></td>
                    <td><img style="width:100px;height:100px" src="<?php echo $data['img'][0] ?? ''; ?>"/></td>
                    <td><input type="text" onchange="update(<?php echo $v['id']; ?>,'invoice',this.value)"
                               class="form-control" value="<?php echo $v['invoice']; ?>"/></td>
                    <td><input type="text" onchange="update(<?php echo $v['id']; ?>,'customer_num',this.value)"
                               class="form-control" value="<?php echo $v['customer_num']; ?>"/></td>
                    <td><input type="text" onchange="update(<?php echo $v['id']; ?>,'customer_name',this.value)"
                               class="form-control" value="<?php echo $v['customer_name']; ?>"/></td>
                    <td>
                        <select class="form-control" onchange="update(<?php echo $v['id']; ?>,'type',this.value)">
                            <option value="1" <?php echo $v['type'] == 1 ? 'selected' : ''; ?>>大货</option>
                            <option value="2" <?php echo $v['type'] == 2 ? 'selected' : ''; ?>>样品</option>
                            <option value="3" <?php echo $v['type'] == 3 ? 'selected' : ''; ?>>其他</option>
                        </select>
                    </td>
                    <td>
                        <select class="form-control" onchange="update(<?php echo $v['id']; ?>,'type2',this.value)">
                            <option value="1" <?php echo $v['type2'] == 1 ? 'selected' : ''; ?>>样品</option>
                            <option value="2" <?php echo $v['type2'] == 2 ? 'selected' : ''; ?>>交通(本地)</option>
                            <option value="3" <?php echo $v['type2'] == 3 ? 'selected' : ''; ?>>快递</option>
                            <option value="4" <?php echo $v['type2'] == 4 ? 'selected' : ''; ?>>其他</option>
                            <option value="5" <?php echo $v['type2'] == 5 ? 'selected' : ''; ?>>差旅(外地)</option>
                        </select>
                    </td>
                    <td><?php echo $data['country'] ?? ""; ?></td>
                    <td><?php echo $data['remark'] ?? ""; ?></td>
                    <td><?php if ($v['status'] == 1) {
                            $msg = '<span class=\'label label-info\'>未审核</span>';
                        } elseif ($v['status'] == 2) {
                            $msg = '<span class=\'label label-success\'>审核通过</span>';
                        } elseif ($v['status'] == 3) {
                            $msg = '审核失败';
                        }
                        echo $msg; ?></td>
                    <td><?php echo $v['pay_time'] > 0 ? '已打款' : '未打款'; ?></td>
                </tr>
            <?php endforeach; ?>
            </tbody>
        </table>
        <div id="page"></div>
    </div>
    <script>

        layui.laypage({
            cont: 'page'
            , pages: <?php echo $this->params['page']['page'];?>
            , curr:<?php echo $this->params['page']['curr'];?>
            , skin: '#5FB878'
            , skip: true
            , jump: function (obj, first) {
                if (!first) {
                    if (window.location.search) {
                        window.location.href = "<?php echo $this->params['page']['url'];?>" + "&p=" + obj.curr;
                    }
                    else {
                        window.location.href = "<?php echo $this->params['page']['url'];?>" + "?p=" + obj.curr;
                    }
                }
            }
        });

        function update(id, param, value) {
            layer.confirm('确认修改', {}, function () {
                $.post('/setting/reimburse-edit', {
                    id: id,
                    param: param,
                    value: value
                }, function (res) {
                    layer.alert(res.msg);
                    if (res.code == 1) {
                        setTimeout(function () {
                            window.location.reload();
                        }, 1000)
                    }
                }, 'json');
            })
        }

    </script>
    <script>
        new Vue({
            el: "#vue_container",
            methods: {
                open: function () {
                    this.$alert("开票资料<br/>" +
                        "公司抬头：义乌市兢赛电子商务有限公司<br/>" +
                        "统一信用代码：9133078232299719XU<br/>" +
                        "地址：浙江省义乌市稠城街道银苑社区金福源商厦A-1901<br/>" +
                        "\n" +
                        "电话；0579-85860268<br/>" +
                        "开户行：<br/>" +
                        "户名：义乌市兢赛电子商务有限公司<br/>" +
                        "帐号：201000157759996<br/>" +
                        "开户机构：浙江省义乌农村商业银行股份有限公司北苑支行前洪分理处<br/>" +
                        "寄件地址;浙江省义乌市稠城街道银苑社区金福源商厦A-1901<br/>",
                        {dangerouslyUseHTMLString: true})
                }
            }
        })
    </script>
<?php echo $this->render('/public/footer'); ?>